﻿using System.Data;
using Core.Library;
using DataObject;

namespace Event.Controls.Album
{
    public partial class MemberInSlide : System.Web.UI.UserControl
    {
        #region variables, constants, properties
        private const int width = 70;
        private const int height = 70;
        private const string LI_FORMAT = @"<li><a href=""{1}"">{2}{0} </a></li>";
        #endregion

        internal bool DataBind(DataTable dt)
        {
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var r = dt.Rows[i];

                var avatar = Utils.Photo.BuildPhoto(
                    source: r[Constants.Table_Members.Member_Avatar].ToString(),
                    title: r[Constants.Table_Members.Member_FullName].ToString(),
                    width: width,
                    height: height);

                    this.ltrList.Text += string.Format(LI_FORMAT, r[Constants.Table_Members.Member_FullName], r[Constants.Table_Members.Url], avatar);
                }
                return true;
            }
            return false;
        }
    }
}